<?php
require_once "globalFunctions.php";

// The event provider contains all event subscriptions and makes callbacks as events are invoked.
class EventProvider {
	private $eventTable;
	function __construct() {
		$this->eventTable = array();
	}
	
	public function addSubscription (&$subscriber, $event) {
		if (!$this->eventTable[$event]) {
			$this->eventTable[$event] = array();
		}
		$this->eventTable[$event][] = $subscriber;
	}
	
	function invokeEvent ($event) {
		if (is_array($this->eventTable[$event])) {
			foreach ($this->eventTable[$event] as $subscriber) {
				global $$subscriber;
				$$subscriber->handleEventCallback($event);
			}
		}
	}
}
?>